/*
 * Copyright (c) 2006-2019, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2019-11-06     yangjie      the first version
 */

#include "gd32vf103v_eval.h"
#include <rtthread.h>

int main(void)
{

#if 1
    /* enable the LED clock */
    rcu_periph_clock_enable(RCU_GPIOB);
    /* configure LED GPIO port */
    gpio_init(GPIOB, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_12);

    gpio_bit_reset(GPIOB, GPIO_PIN_12);

    while (1)
    {
        /* insert 500 ms delay */
        rt_thread_mdelay(300);

        /* toggle the LED */
        gpio_bit_write(GPIOB, GPIO_PIN_12, (bit_status)(1 - gpio_input_bit_get(GPIOB, GPIO_PIN_12)));
    }

#else

    gd_eval_led_init(LED1);
    while (1)
    {
        gd_eval_led_on(LED1);
        rt_thread_mdelay(500);
        gd_eval_led_off(LED1);
        rt_thread_mdelay(500);
    }

#endif
}
